#include <stdio.h>
#include <stdlib.h>
void swap(int &a, int &b)
{
	int t = a;
	a = b;
	b = t;
}

void d_bubble(int a[], int n)
{
	int low = 0;
	int high = n - 1;
	while (low < high)
	{
		for (int i = low; i < high; i++)
		{
			if (a[i] > a[i + 1])
				swap(a[i], a[i + 1]);
		}
		high--;
		for (int j = high; j > low; j--)
		{
			if (a[j] < a[j - 1])
				swap(a[j], a[j - 1]);
		}
		low++;
	}
}

int main()
{
	/*******************code*******************/
	int a[] = {4, 3, 10, 8, 14, 13, 7, 30, 26, 17};
	d_bubble(a, 10);
	for (int i = 0; i < 10; i++)
		printf("%3d", a[i]);
	/******************************************/
	printf("\n\n****************************\n");
	printf("Press Enter key to continue\n");
	getchar();
	return 0;
	/******************************************/
}
